package com.mr.orderclient.utils;

import lombok.Getter;

/**
 * @ClassName: ConstantEnum
 * @User MRui
 * @Description: TODO描述：枚举类
 * @date 2018.09.19 23:14
 */
@Getter
public enum ConstantEnum {
    /**成功 */
    SUCCESS(0,"成功"),
    /**商品状态 */
    PRODUCT_UP(100,"在架"),
    PRODUCT_DOWN(101,"下架"),
    PRODUCT_STATUS_ERROR(102,"商品状态不正确"),
    /** 订单状态*/
    ORDER_NEW(200,"新订单"),
    ORDER_FINISHED(201,"完结"),
    ORDER_CANCEL(202,"已取消"),
    ORDER_CANCEL_SUCCESS(203,"订单取消成功"),
    ORDER_FINISH_SUCCESS(204,"订单完结成功"),
    /**支付状态*/
    PAY_WAIT(300,"等待支付"),
    PAY_SUCCESS(301,"支付成功"),
    /**异常信息*/
    EXCEPTION_PRODUCT_NOT_EXIST(400,"商品不存在"),
    EXCEPTION_PRODUCT_STOCK_ERROR(401,"库存不正确"),
    EXCEPTION_ORDER_NOT_EXIST(402,"订单不存在"),
    EXCEPTION_ORDER_DETAIL_NOT_EXIST(403,"订单详情不存在"),
    EXCEPTION_ORDER_STATUS_ERROR(404,"订单状态不正确"),
    EXCEPTION_UPDATE_FAIL(405,"订单状态不正确"),
    EXCEPTION_DETAIL_EMPTY(406,"订单详情为空"),
    EXCEPTION_PAY_STATUS_ERROR(407,"订单支付状态不正确"),
    EXCEPTION_PARAM_ERROR(408,"参数不正确"),
    EXCEPTION_CART_EMPTY(409,"购物车为空"),
    EXCEPTION_WECHAT_ERROR(410,"微信授权失败"),
    EXCEPTION_WECHAT_NOTIFY_MONEY_VERIFY_ERROR(411,"微信支付异步通知金额校验不通过"),
    /**登陆*/
    LOGIN_FAIL(501,"登录失败"),
    LOGOUT_SUCCESS(601,"登出成功"),
    ;

    private int code;
    private String message;

    ConstantEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
    * User (作者): MRui
    * TODO (描述)：根据code返回message
    * Data：2018.09.28 22:16
    */
    public static String getConstantEnum(int code){

        for (ConstantEnum constantEnum:ConstantEnum.values()){
            if (constantEnum.getCode()==code){
                return constantEnum.getMessage();
            }
        }
        return null;
    }
}
